<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #box1{
            width: 100px;
            height: 100px;
            background: yellow;
        }
    </style>
    <script>
        window.onload = function(){
          //读取box1样式
          var box1 = document.getElementById("box1");
          var btn01 = document.getElementById("btn01");
          btn01.onclick = function(){
              /*
              获取元素当前显示的样式
              语法：元素.currentStyle.样式名
                它可以用来读取当前正在显示的样式
              */
              alert(box1)
          }

        };

    </script>
</head>
<body>
    <button id="btn01">点我一下</button>
    <br><br>
    <div id="box1" style="width: 200px;"></div>
</body>
</html>